import startAudio from '../static/music/start.wav'
import fireAudio from '../static/music/fire.wav'
import bulletAudio from '../static/music/blast.wav'

export default {
  el(type: string) : HTMLElement {
    // 创建一个audio标签
    let element = document.createElement('audio')
    element.src = type === 'start' ? startAudio : type === 'fire' ? fireAudio : bulletAudio
    return element
  },
  async start() {
    const el = <HTMLAudioElement> this.el('start')
    // 添加到body中
    document.body.appendChild(el)
    // 音频播放
    await el.play()
  },
  async fire() {
    const el = <HTMLAudioElement> this.el('fire')
    // 音频播放
    await el.play()
  },
  async blast() {
    const el = <HTMLAudioElement> this.el('blast')
    // 音频播放
    await el.play()
  }
}
